//
//  ViewController.swift
//  ReactNativeIOS
//
//  Created by chenliang on 2017/3/3.
//  Copyright © 2017年 chenliang. All rights reserved.
//

import UIKit
import React

class ViewController: YYController {
    
    var imageUpload: ImageUpload?
    
    override var preferredStatusBarStyle: UIStatusBarStyle {
        return UIStatusBarStyle.default
    }
    
    override func yy_configNaviBar(_ naviBar: UINavigationBar!) {
        naviBar.barStyle = .black
        navigationController?.isNavigationBarHidden = true
    }

    override func viewDidLoad() {
        super.viewDidLoad()
        
        let reactnativeUrl = "http://" + (UserDefaults.standard.string(forKey: "developIP") ?? "") + ":8081/index.ios.bundle?platform=ios"
        let jsCodeLocation = UserDefaults.standard.bool(forKey: "develop") ? URL(string: reactnativeUrl) : Bundle.main.url(forResource: "main", withExtension: "jsbundle")
        
        let mockData:NSDictionary = ["config":
            ["token":"xxxx"]
        ]
        
        let rootView = RCTRootView(
            bundleURL: jsCodeLocation,
            moduleName: "ZhendeIOSApp",
            initialProperties: mockData as [NSObject : AnyObject],
            launchOptions: nil
        )
        
        view = rootView
        
        RNEventManager.getInstance().setBridge(rootView?.bridge)
        RNEventManager.getInstance().registerSupportMethods(["GotoRoute"])
        
        registerRNAction()
        
    }
    
    

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }


}

